import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class greedy {
	@SuppressWarnings("rawtypes")
	private static List<List> block_list = new ArrayList<List>();
	private static List<block> r1 = new ArrayList<block>();
	private static List<block> r2 = new ArrayList<block>();
	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		String input = args[0];
		float Threshold = Float.parseFloat(args[1]);
		readfile(input);
		for(int i = 0 ; i < block_list.size() ; i++) {
			if(block_list.get(i).size() == 1) {
				r1.addAll(block_list.get(i));
			}else {
				r1.addAll(g(sort(block_list.get(i)), Threshold));
			}
			
		}
		r2 = g(sort(r1), Threshold);
		int[] result = new int[r2.size()];
		for(int i = 0 ; i < result.length ; i++) {
			result[i] = r2.get(i).getBlock_id();
		}
		writefile(result, input);
	}
	
	public static void readfile(String filename) {
		int i = -1;
		String id = "";
		List<block> list = new ArrayList<block>();
		try(BufferedReader br = new BufferedReader(new FileReader(filename))){
			String line;
			while((line = br.readLine()) != null) {
				i++;
				String[] strs = line.split("\t");
				String query_id = strs[0];
				int qry_start = Integer.parseInt(strs[2]);
				int qry_end = Integer.parseInt(strs[3]);
				int ref_start = Integer.parseInt(strs[7]);
				int ref_end = Integer.parseInt(strs[8]);
				int block_len = Integer.parseInt(strs[10]);
				block b = new block(query_id, i, qry_start, qry_end, ref_start, ref_end, block_len);
				if(id.equals(query_id)) {
					list.add(b);
				}else {
					if(list.size() == 0) {
						list.add(b);
						id = query_id;
					}else {
						List<block> l = new ArrayList<block>();
						for(int j = 0; j < list.size(); j++) {
							l.add(list.get(j));
						}
						block_list.add(l);
						list.clear();
						id = query_id;
						list.add(b);
					}
				}
			}
			if(list.size() != 0) {
				List<block> l = new ArrayList<block>();
				for(int j = 0; j < list.size(); j++) {
					l.add(list.get(j));
				}
				block_list.add(l);
				list.clear();
			}
		}catch(IOException e) {
			e.printStackTrace();
		}
	}
	
	public static void writefile(int[] result, String input) {
		try(BufferedReader br = new BufferedReader(new FileReader(input))){
			String line;
			int index = -1;
			while((line = br.readLine()) != null) {
				index++;
				for(int i = 0 ; i < result.length ; i++) {
					if(result[i] == index) {
						System.out.println(line);
						break;
					}
				}
			}
		}catch(IOException e) {
			e.printStackTrace();
		}
	}
	
	public static List<block> sort(List<block> block_list) {
		List<block> aln_list_sorted = new ArrayList<block>();
		if(block_list.size() == 1) {
			aln_list_sorted = block_list;
		}else {
			while(block_list.size() != 0) {
				int index = 0;
				int least_start = block_list.get(0).getRef_start();
				for(int i = 0 ; i < block_list.size() ; i++) {
					if(least_start > block_list.get(i).getRef_start()) {
						least_start = block_list.get(i).getRef_start();
						index = i;
					}
				}
				aln_list_sorted.add(block_list.get(index));
				block_list.remove(index);
			}
		}
		return aln_list_sorted;
	}
	
	//sorted list!
	public static List<block> g(List<block> list, float Threshold){
		List<block> selected = new ArrayList<block>();
		selected.add(list.get(0));
		int rec_block_id = 0;
		for(int i = 0 ; i < list.size() ; i++) {
			if(!isOverlap(list.get(rec_block_id).getQry_start(), list.get(rec_block_id).getQry_end(), 
					list.get(i).getQry_start(), list.get(i).getQry_end(), list.get(rec_block_id).getBlock_len(), Threshold)) {
				selected.add(list.get(i));
				rec_block_id = i;
			}
		}
		
		return selected;
	}
	
	public static boolean isOverlap(int former_start, int former_end, int latter_start, int latter_end, int block_len, float Threshold) {
		if(former_start <= latter_start && former_end >= latter_end || former_start >= latter_start && former_end <= latter_end) {
			return true;
		}else if(former_start >= latter_start) {
			if(former_end >= latter_start) {
				return false;
			}else {
				if((former_end - latter_start) < (block_len * Threshold)) {
					return false;
				}else {
					return true;
				}
			}
		}else {
			if(former_start <= latter_end) {
				return false;
			}else {
				if((former_start - latter_end) < (block_len * Threshold)) {
					return false;
				}else {
					return true;
				}
			}
		}
	}
	
}

class block{
	private int block_id = -1;
	private String query_id;
	private int qry_start = -1;
	private int qry_end = -1;
	private int ref_start = -1;
	private int ref_end = -1;
	private int block_len = -1;
	
	public block(String id, int bi, int qs, int qe, int rs, int re, int bl) {
		query_id = id;
		block_id = bi;
		qry_start = qs;
		qry_end = qe;
		ref_start = rs;
		ref_end = re;
		block_len = bl;
	}

	public String getQuery_id() {
		return query_id;
	}

	public int getQry_start() {
		return qry_start;
	}

	public int getQry_end() {
		return qry_end;
	}

	public int getRef_start() {
		return ref_start;
	}

	public int getRef_end() {
		return ref_end;
	}

	public int getBlock_len() {
		return block_len;
	}
	
	public int getBlock_id() {
		return block_id;
	}
	

	public block() {
		
	}
	
}
